<html>
<head>
    <meta charset="utf-8">
</head>
<body>


<?php
$year = $_POST['year'];
$level = $_POST['level'];
$area = $_POST['area'];

$config = parse_ini_file("config/db_config.ini");
$server = $config["server"];
$username = $config["username"];
$password = $config["password"];
$database = $config["database"];
$link = mysqli_connect($server, $username, $password, $database);


//处理年份
if ($year == "不限")
    $year = "'%'";
else
    $year = "'" . $year . "%'";


//处理级别
switch ($level) {
    case "弱于热带低压":
        $level = "'0'";
        break;
    case "热带低压":
        $level = "'1'";
        break;
    case "热带风暴":
        $level = "'2'";
        break;
    case "强热带风暴":
        $level = "'3'";
        break;
    case "台风":
        $level = "'4'";
        break;
    case "强台风":
        $level = "'5'";
        break;
    case "超强台风":
        $level = "'6'";
        break;
    case "强于超强台风":
        $level = "'9'";
        break;
    default :
        $level = "'%'";
}


$sql = "SELECT * FROM `typhoon_total` WHERE flat=0 and num like " . $year . " and level like " . $level;
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_row($result);


echo '<table border="1" cellspacing="0px" cellpadding="2px" align="center">';
echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></td></tr>';
echo '<tr><td><h1>☆☆>>符合查询结果的台风有<br /></h1></tr></td>';
echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></td></tr>';

while ($row != null) {

    echo '<tr><td><h1>&nbsp;&nbsp;&nbsp;>>序号 : ' . floor($row[0] / 10000) . "年第" . sprintf("%03d", ($row[0] % 10000)) . "号气旋" . '</h1></tr></td>';
    echo '<tr><td><h1>&nbsp;&nbsp;&nbsp;>>名称 : ' . $row[2] . '</h1></tr></td>';
    echo "<tr><td><h1>&nbsp;&nbsp;&nbsp;>>展示 :<a href = \"show.php?num=" . $row[0] . "&count=" . $row[4] . "&table=typhoon_detail\"target=\"_top\">" . "点击此处进入展示页面" . "</a></h1></tr></td>";
    echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></tr></td>';

    $row = mysqli_fetch_row($result);
}
echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></tr></td></table>';

?>

</body>
</html>